import Vue from 'vue'
import VueRouter from 'vue-router'
import { routers,appRouter } from './router'
import Util from '@/utils/util'
// import store from '../store/index' 
Vue.use(VueRouter)
const RouterConfig = {
    // mode: 'history',
    routes: routers
};
export const router = new VueRouter(RouterConfig);

router.beforeEach((to, from, next) => {
    if (to.name == "Login") {
     next("/index");
     return ;
    }
    next();
    // let user = localStorage.getItem('token');
    // if (to.name == "Login") {
    //     if (user == null || user == "" || user == undefined) {
    //         next();
    //     } else {
    //         next("/index");
    //     }
    // } else {
    //     if (user == null || user == "" || user == undefined) {
    //         next("/login");
    //     } else {
    //         next();
    //     }
    // }
})
router.afterEach((to) => {
   if (!to.name == "Login"){
    Util.openNewPage(router.app, to.name, to.params, to.query);
    // iView.LoadingBar.finish();
    window.scrollTo(0, 0);
    }
});

// export default router;